﻿using System;
using System.Windows.Forms;

namespace YArchitech.Temp
{
	internal class HYPipeSpecificationRow : DataGridViewRow
	{
		public void Binding(HYPipeSpecification sp)
		{
			this.m_Spec = sp;
			base.Cells[0].SetValue(sp.DN);
			base.Cells[1].SetValue(sp.Diameter, 3);
			base.Cells[2].SetValue(sp.VelocityRange.Min, 3);
			base.Cells[3].SetValue(sp.VelocityRange.Max, 3);
			base.Cells[4].SetValue(sp.RmRange.Min, 3);
			base.Cells[5].SetValue(sp.RmRange.Max, 3);
			base.Cells[6].SetValue(sp.LoadRange.Min, 3);
			base.Cells[7].SetValue(sp.LoadRange.Max, 3);
		}

		public HYPipeSpecification GetSpec()
		{
			if (this.m_Spec == null)
			{
				this.m_Spec = new HYPipeSpecification();
			}
			this.m_Spec.DN = base.Cells[0].GetIntValue();
			this.m_Spec.Diameter = base.Cells[1].GetDoubleValue();
			double doubleValue = base.Cells[2].GetDoubleValue();
			double doubleValue2 = base.Cells[3].GetDoubleValue();
			this.m_Spec.VelocityRange.Set(doubleValue, doubleValue2);
			double doubleValue3 = base.Cells[4].GetDoubleValue();
			double doubleValue4 = base.Cells[5].GetDoubleValue();
			this.m_Spec.RmRange.Set(doubleValue3, doubleValue4);
			return this.m_Spec;
		}

		private HYPipeSpecification m_Spec;

		private enum CellIndex
		{
			DN,
			Diameter,
			MinV,
			MaxV,
			MinRm,
			MaxRm,
			MinH,
			MaxH
		}
	}
}
